package com.srwl.mytx.im.conversation;

import android.content.Context;
import android.content.Intent;

import com.alibaba.fastjson.JSONObject;
import com.srwl.mytx.Constant;
import com.srwl.mytx.R;
import com.srwl.mytx.activity.ConversationActivity.TaskNotifyActivity;
import com.srwl.mytx.activity.ConversationActivity.TransferAuthorityNotifyActivity;
import com.srwl.mytx.domain.ConversationData;
import com.srwl.mytx.domain.Message;
import com.srwl.mytx.domain.Task;
import com.srwl.mytx.im.MessageHandler;


/**
 * 权限移交会话
 */
public class TransferAuthorityConversation extends SystemNotifyConversation {
    public TransferAuthorityConversation(Context context,ConversationData data, MessageHandler messageHandler, MessageUnReadCountListener unReadCountListener) {
        super(context,data, messageHandler, unReadCountListener);
    }

    @Override
    public void receivedMessage(Message message) {
        // message.setId(message.getFromId());
        message.setState(Constant.INVITE_MESSAGE_STATUS_APPLY);
        saveMessageAndRefreshView(message);

    }

    @Override
    public String getTitle() {
        return "权限移交通知";
    }

    @Override
    public int getIconResourceId() {
        return R.drawable.tx_authority_icon;
    }

    @Override
    public String getContent() {
        if (lastMessage == null) {
            return "";
        }
        return lastMessage.getContent() != null ? lastMessage.getContent() : "您收到了新的权限移交通知";
    }


    @Override
    public void openConversation(Context context) {
        if (unReadCount > 0) {
            if (unReadCountListener != null) {
                unReadCountListener.onReadCountReduce(unReadCount);
            }
            messageHandler.setMessageReadByConversationId(cId);
            unReadCount = 0;
        }
        context.startActivity(new Intent(context, TransferAuthorityNotifyActivity.class));
    }
}
